package com.example.asuper.check.Helper;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Superb on 2016/2/26.
 */
public class StringHelper {
    //获取当前时间字符串
    public static String getCurrentTime() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date curDate = new Date(System.currentTimeMillis());
        String str = formatter.format(curDate);
        return str;
    }

    //获取分割字符串转义符
    public static String getSpliteStr(String spilte) {
        String codeResult="";
        switch (spilte.trim()) {
            case "|":
                codeResult= "\\|";
                break;
            case "~":
                codeResult= "\\~";
                break;
            case ",":
                codeResult= "\\,";
                break;
            case "制表符Tab":
                codeResult= "\t";
                break;
        }
        return codeResult;
    }

    //获取分隔符
    public static int getSpliteIndex(String spilte){
        switch (spilte.trim()) {
            case "\\|":
                return 0;
            case "\\~":
                return 1;
            case "\\,":
                return 2;
            case "\t":
                return 3;
        }
        return 0;
    }

    public static String getSpliteM(String splite){
        String codeResult="";
        switch (splite.trim()) {
            case "\\|":
                codeResult= "|";
                break;
            case "\\~":
                codeResult= "~";
                break;
            case "\\,":
                codeResult= ",";
                break;
            case "\t":
                codeResult= "\t";
                break;
        }
        return codeResult;
    }
}
